import { getToken, setToken, removeToken } from "@/utils/auth";
import { defineStore } from "pinia";


const useOrderStore = defineStore("order", {
  state: () => ({
    token: getToken(),
    settlement: [],
    currentOrderId: '', //当前的结算订单的 id
    catData: [], // 购物车数据
    roles: Array(),
    permissions: [],
  }),
  actions: {
    addSettlement(val) {
      this.settlement = val
    },
    addCurrentOrderId(val) {
      this.currentOrderId = val
    }
    // 登录
    // login(userInfo: LoginForm) {
    //   const username = userInfo.username.trim();
    //   const password = userInfo.password;
    //   const code = userInfo.code;
    //   const uuid = userInfo.uuid;
    //   return new Promise((resolve, reject) => {
    //     login(username, password, code, uuid)
    //       .then((res: any) => {
    //         setToken(res.token);
    //         this.token = res.token;
    //         resolve(null);
    //       })
    //       .catch((error) => {
    //         reject(error);
    //       });
    //   });
    // },
  },
});

export default useOrderStore;
